<template>
	<view>
		<uni-list>
			<uni-list v-for="item,index in list" :key="index" >
				<uni-list-chat :title="item.name" 
				:note="item.department" 
				:avatarCircle="true" 
				:avatar="item.icon"
				:show-badge="true"
				:badge-text="item.txt"
				></uni-list-chat>
			<!-- 	<button type="primary" @click="to">跳转</button> -->
			</uni-list>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						icon: "/static/1.png",
						txt: 6
					},
					{

						icon: "/static/logo.png",
						txt: 26
					}]
			}
		},
		methods:{
			// to(){
			// 	uni.switchTab({
			// 		url:"/pages/home/home"
			// 	})
			// }
		},
		onLoad(){
			
			uni.request({
				url:'  http://localhost:8090/freshmenapp/user/list',
				method:'POST',
				data:{},
				success: res => {
					console.log(res.data);
					if(res.data.success === true){
						this.list = res.data.list.map((item,index) =>({
							...item,
							...this.list[index]
						}))
						uni.showToast({
							title:'成功',
							icon:"success"
						});
					}else{
						uni.showToast({
							title:'失败',
							icon:'error'
						});
					}
				},
				// fail:(err) => {
				// 	uni.showToast({
				// 		title:'网络错误',
				// 		icon:'error'
				// 	});
				// },
				// complete:() => {}
			})
		}
	}
</script>

<style>

</style>